<template>
    <el-card>
        <el-table :data="categoryTree" row-key="name" lazy :load="load" 
        :tree-props="{ hasChildren: 'has_children' }" v-loading="loading">
            <el-table-column prop="name" label="名称"></el-table-column>
            <el-table-column prop="id" label="id"></el-table-column>
        </el-table>
    </el-card>
</template>

<script setup>
import {useCategory} from '@/hooks/category.js';

const {categoryTree,loading,categoryList,categoryMap} = useCategory();

//懒加载
const load = (row, treeNode, resolve) => {
    console.log('懒加载');
    console.log(row);
    setTimeout(() => {
        resolve(row.children)
    }, 500);
}

</script>